package com.xoa.dev.workFlow.controller;

import com.xoa.dao.common.SysCodeMapper;
import com.xoa.model.common.SysCode;
import com.xoa.util.AjaxJson;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.List;

@Controller
@RequestMapping("/smsRemind")
public class WorkFlowRemindController {

    @Autowired
    SysCodeMapper sysCodeMapper;

    @RequestMapping("/getRemindFlag")
    @ResponseBody
    public AjaxJson getRemindFlag(HttpServletRequest request, String type) {

        AjaxJson ajaxJson = new AjaxJson();
        try {
            SysCode sysCode = null;
            String typeArray[] = type.split(",");
            List<SysCode> list = new ArrayList<SysCode>();
            for (int i = 0; i < typeArray.length; i++) {
                sysCode = sysCodeMapper.getSmsIsRemind(typeArray[i]);
                list.add(sysCode);
            }
            ajaxJson.setObj(list);
            ajaxJson.setFlag(true);
        } catch (Exception e) {
            ajaxJson.setFlag(false);
            ajaxJson.setMsg(e.getMessage());
        }
        return ajaxJson;

    }


}
